package com.anjie.powerproject.repository;


import com.anjie.powerproject.entity.TaskConfig;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;

public interface TaskConfigRepository extends JpaRepository<TaskConfig, Integer> {
    @Modifying
    @Transactional
    @Query(nativeQuery = true,value="delete from task_config where dev_code = ?1")
    Integer deleteByDevCode(String devCode);

    @Modifying
    @Transactional
    @Query(nativeQuery = true,value="delete from task_config where point_id = ?1")
    Integer deleteByPointId(Integer pointId);


    @Query(nativeQuery = true,value="select * from task_config where dev_code = ?1")
    List<TaskConfig> getByDevCode(String devCode);

    @Query(nativeQuery = true,value="select * from task_config where point_id = ?1")
    List<TaskConfig> getByPointId(Integer pointId);

    @Modifying
    @Transactional
    @Query(nativeQuery = true,value="delete from task_config where id = ?1")
    Integer deleteByTaskConfigId(Integer id);

}
